package com.kfm.pm;

import java.util.Arrays;

public class Exec01 {


    public static void main(String[] args) {
        String str = "abade";
        String str2 = "aade";
        searchSomething(str, str2);
    }

    public static void searchSomething(String str1, String str2) {
        int m = str1.length();
        int n = str2.length();
        int[][] arr = new int[m + 1][n + 1];
        for (int i = 1; i < m + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                if (str1.charAt(i - 1) == str2.charAt(j - 1)) {
                    arr[i][j] = arr[i - 1][j - 1] + 1;
                } else {
                    arr[i][j] = Math.max(arr[i][j - 1], arr[i - 1][j]);
                }
            }
        }

        System.out.println("arr数组");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(Arrays.toString(arr[i]));
        }
        System.out.println(arr[m][n]);
    }
}
